//
//  ButtomBtn.m
//  ECO
//
//  Created by zl on 2019/9/27.
//  Copyright © 2019 谷银行. All rights reserved.
//

#import "ButtomBtn.h"

@implementation ButtomBtn

- (UIButton *)BjBtn{
    if (!_BjBtn) {
        _BjBtn = [[UIButton alloc]init];
        _BjBtn.backgroundColor = [UIColor colorWithHexString:@"#FFBB3E"];
        [_BjBtn setTitle:@"编辑" forState:UIControlStateNormal];
        _BjBtn.layer.cornerRadius = 18;
        _BjBtn.layer.masksToBounds = YES;
        [_BjBtn addTarget:self action:@selector(bjbtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _BjBtn;
}
- (UIButton *)TjBtn{
    if (!_TjBtn) {
        _TjBtn = [[UIButton alloc]init];
        _TjBtn.backgroundColor = [UIColor colorWithHexString:@"#00DAAF"];
        [_TjBtn setTitle:@"添加" forState:UIControlStateNormal];
        _TjBtn.layer.cornerRadius = 18;
        _TjBtn.layer.masksToBounds = YES;
    }
    return _TjBtn;
}
- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        [self addSubview:self.BjBtn];
        [self addSubview:self.TjBtn];
        [self BtnFrame];
    }
    return self;
}
- (void)BtnFrame{
    [_BjBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(15);
        make.width.equalTo(@((kScreenWidth - 50)/2));
        make.height.equalTo(@(38));
    }];
    [_TjBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self.mas_right).offset(-15);
        make.width.equalTo(@((kScreenWidth - 50)/2));
        make.height.equalTo(@(38));
    }];
}
- (void)bjbtn:(UIButton *)send{
    NSLog(@"编辑");
    if (self.delegate && [self.delegate respondsToSelector:@selector(ButtomBtnClick)]) {
        [self.delegate performSelector:@selector(ButtomBtnClick) withObject:nil];
    }
}

@end
